home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / usr_-_Usr_Files / INCLUDE / NAN.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  3KB  |  89 lines

  1. /* `NAN' constant for IEEE 754 machines.
  2.  
  3. Copyright (C) 1992 Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5.  
  6. The GNU C Library is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU Library General Public License as
  8. published by the Free Software Foundation; either version 2 of the
  9. License, or (at your option) any later version.
  10.  
  11. The GNU C Library is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14. Library General Public License for more details.
  15.  
  16. You should have received a copy of the GNU Library General Public
  17. License along with the GNU C Library; see the file COPYING.LIB.  If
  18. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  19. Cambridge, MA 02139, USA.  */
  20.  
  21. #ifndef    _NAN_H
  22.  
  23. #define    _NAN_H    1
  24.  
  25. /* IEEE Not A Number.  */
  26.  
  27. #include <endian.h>
  28.  
  29. #if    __BYTE_ORDER == __BIG_ENDIAN
  30. #define    __nan_bytes        { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 }
  31. #endif
  32.  
  33. #if    __BYTE_ORDER == __LITTLE_ENDIAN
  34. #define    __nan_bytes        { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }
  35. #endif
  36.  
  37. #ifdef __i386__
  38. /* Signal double NaN. */
  39. #define    __snan_bytes        { 0, 0, 0x0f, 0, 0, 0, 0xf0, 0x7f }
  40. /* Quiet double NaN, It is also indefinite(?). */
  41. #define    __qnan_bytes        { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }
  42. /* Signal float NaN. */
  43. #define    __snanf_bytes        { 0, 0x0f, 0x80, 0x7f }
  44. /* Quiet float NaN. It is also indefinite(?). */
  45. #define    __qnanf_bytes        { 0, 0, 0xc0, 0x7f }
  46. #endif
  47.  
  48. #ifdef    __GNUC__
  49. #define    NAN \
  50.   (__extension__ ((union { unsigned char __c[8];              \
  51.                double __d; })                  \
  52.           { __nan_bytes }).__d)
  53.  
  54. #ifdef __i386__
  55. #define    _SNAN \
  56.   (__extension__ ((union { unsigned char __c[8];              \
  57.                double __d; })                  \
  58.           { __snan_bytes }).__d)
  59. #define    _QNAN \
  60.   (__extension__ ((union { unsigned char __c[8];              \
  61.                double __d; })                  \
  62.           { __qnan_bytes }).__d)
  63. #define    _SNANF \
  64.   (__extension__ ((union { unsigned char __c[4];              \
  65.                float __f; })                  \
  66.           { __snanf_bytes }).__f)
  67. #define    _QNANF \
  68.   (__extension__ ((union { unsigned char __c[4];              \
  69.                float __f; })                  \
  70.           { __qnanf_bytes }).__f)
  71. #endif
  72. #else    /* Not GCC.  */
  73. static __const char __nan[8] = __nan_bytes;
  74. #define    NAN    (*(__const double *) __nan)
  75.  
  76. #ifdef __i386__
  77. static __const char __snan[8] = __snan_bytes;
  78. #define    _SNAN    (*(__const double *) __snan)
  79. static __const char __qnan[8] = __qnan_bytes;
  80. #define    _QNAN    (*(__const double *) __qnan)
  81. static __const char __snanf[4] = __snanf_bytes;
  82. #define    _SNANF    (*(__const float *) __snanf)
  83. static __const char __qnanf[4] = __qnanf_bytes;
  84. #define    _QNANF    (*(__const float *) __qnanf)
  85. #endif
  86. #endif    /* GCC.  */
  87.  
  88. #endif    /* nan.h */
  89.